package ch.janotta.slawo.da.tables;

import ch.janotta.slawo.da.Ability;
import ch.janotta.slawo.da.Entity;
import ch.janotta.slawo.da.Talent;
import ch.janotta.slawo.da.modifier.Modifier;
import ch.janotta.slawo.da.modifier.ModifierFactory;
import ch.janotta.slawo.utilities.Dice;

public class RogueModifiersTable extends CharacterClassModifiersTable {
  private static final Ability[] PRIMARY_ABILITIES = new Ability[] {
      Ability.Communication,
      Ability.Dexterity,
      Ability.Perception,
  };

  private static final Ability[] SECONDARY_ABILITIES = new Ability[] {
      Ability.Constitution,
      Ability.Cunning,
      Ability.Magic,
      Ability.Strength,
      Ability.Willpower,
  };

  private Modifier[][] levelModifiers = new Modifier[][] {
      // Level 1
      new Modifier[] {
          ModifierFactory.getInstance(Talent.Backstab),
          ModifierFactory.getInstance(Talent.RoguesArmor),
      },
      // Level 2
      new Modifier[] {
          
      },
  };

  private final int baseHealth = 25;
  private final Talent[] startingWeaponGroups = new Talent[] {
      Talent.Bows,
      Talent.Brawling,
      Talent.LightBlades,
      Talent.Staves,
  };
  private final Talent[] possibleStartingTalents = new Talent[] {
      Talent.Contacts,
      Talent.Scouting,
      Talent.Thievery,
  };

  @Override
  public Ability[] getPrimaryAbilities() {
    return PRIMARY_ABILITIES;
  }

  @Override
  public Ability[] getSecondaryAbilities() {
    return SECONDARY_ABILITIES;
  }

  @Override
  public int getStartingHealth(Entity entity) {
    return baseHealth + entity.getConstitution() + Dice.getD6();
  }

  @Override
  public int getLevelUpHealth(Entity entity) {
    return entity.getConstitution() + Dice.getD6();
  }

  @Override
  public int getStartingMana(Entity entity) {
    return 0;
  }

  @Override
  public int getLevelUpMana(Entity entity) {
    return 0;
  }

  @Override
  public Talent[] getStartingWeaponGroups() {
    return startingWeaponGroups;
  }

  @Override
  public Talent getStartingTalent() {
    int lastPossibleTalent = possibleStartingTalents.length;
    int randomTalentNumber = Dice.getRandomNumber(lastPossibleTalent);
    int tableIndex = randomTalentNumber - 1; // random number starts with 1, array indexes start with 0
    return possibleStartingTalents[tableIndex];
  }

  @Override
  public Modifier[] getLevelUpModifiers(int newLevel) {
    return levelModifiers[newLevel - 1];
  }
}
